export enum FontType {
  default,
  monospace
}

const emojiAppend = `"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", emoji`;

const getFontAppend = (type = FontType.default): string => {
  switch (type) {
    case FontType.monospace :
      return `monospace, ${emojiAppend}`;
  }
  return `system-ui, -apple-system, sans-serif, ${emojiAppend}`;
};

export const filterFont = (font: unknown, type = FontType.default): string => {
  if (font == null) return getFontAppend(type);
  if (Array.isArray(font)) {
    return [
      ...font.filter(Boolean).map((item) => `"${item}"`),
      getFontAppend(type),
    ].filter(Boolean).join(',');
  }
  if (typeof font !== 'string' || font.trim() === '') {
    return getFontAppend(type);
  }
  return [font, getFontAppend(type)].join(',');
};